-
Notifications
You must be signed in to change notification settings - Fork 866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add 'ipfs' to PATH on macOS and Linux #896
Conversation
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
@lidel @olizilla need your feedback about what we currently do: I don't feel great about the idea of doing nothing when the user has IPFS already, but I think we have margin to play since we use a script and don't link directly to the binary. Could you please review the scripts to see if they're OK? |
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
WIP update on Linux: only working on deb. |
As per electron-userland/electron-builder#3436 it seems we can't run install scripts on some platforms. Ideally we could do everything on runtime. @lidel is there a way on Linux to ask permission temporarily so we can modify /usr/local/bin? |
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
This fixes .deb to properly create/remove symlinks to ipfs and ipfs-desktop during the install. Previous version created broken symlink, and wrapper script was not included in app bundle extracted into /opt/ We now include wrapper script in resources/bin/ipfs.sh Uninstall removes broken symlinks, making it safe if someone has ipfs installed by other means
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did quick smoke-test and found issues with afterInstall
in .deb
:
ipfs-desktop
was no longer added toPATH
, symlink at/usr/local/bin/ipfs-desktop
was no longer created during install (missing from customafter-install.sh
)- Created symlink for
ipfs
pointed at non-existing file:
$ ls /usr/local/bin/ipfs
lrwxrwxrwx 1 root staff 27 Apr 6 21:57 /usr/local/bin/ipfs -> /var/lib/assets/bin/ipfs.sh
$ ls /var/lib/assets/bin/ipfs.sh
ls: cannot access '/var/lib/assets/bin/ipfs.sh': No such file or directory
I fixed above and ensured wrapper script is included in bundled app under resources/bin/ipfs.sh
– it should work now as expected, at least with .deb
(I tested on Debian).
Note that I changed assets/bin/ipfs.sh
– it did not work correctly on Linux, I assumed was also broken on MacOS (cc @olizilla), but let me know if I introduced any regressions.
If so, we may need to set different path in ipfs=
on each platform.
@lidel is there a way on Linux to ask permission temporarily so we can modify /usr/local/bin?
Some systems have graphical sudo
installed, such as gksudo
/gksu
, but that is not always enough, user needs to be added to privileged group first.
There is no easy way, because regular desktop app asking for root is considered a bad practice and will raise serious eyebrows. Adding symlink on install is the only viable option on Linux IMO.
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
deb: | ||
afterInstall: assets/build/after-install.sh | ||
afterRemove: assets/build/after-remove.sh | ||
|
||
snap: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it work for snap
installs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned above, it doesn't. Only on deb
for now.
} | ||
|
||
// Don't make any changes if IPFS already exists... | ||
if (fs.existsSync('/usr/local/bin/ipfs')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
install.sh
from a go-ipfs distribution will try to install in either /usr/local/bin
or /usr/bin
https://github.com/ipfs/go-ipfs/blob/622dbf7f266e513c6de00cddc5cb851aa5cbfe61/cmd/ipfs/dist/install.sh#L9
perhaps we should try and exec ipfs
here to see if it exists on the users path.
|
||
// Don't make any changes if IPFS already exists... | ||
if (fs.existsSync('/usr/local/bin/ipfs')) { | ||
logger.info('[ipfs on path] was not added, already exists') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a subsequent PR, we could prompt the user here.
"you appear to have a version of the ipfs
command line tool already. Would you like to let ipfs-desktop replace it with the a version that it can keep up to date?"
...that kind of thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the goal. I'm just making this one as simple as possible.
Co-Authored-By: hacdias <hacdias@gmail.com>
License: MIT Signed-off-by: Marcin Rataj <lidel@lidel.org>
woo haa! It works! $ cat `which ipfs`
#!/usr/bin/env bash
# Get the full path of "resources/" directory (resolving the symlink if needed)
resources=$(dirname "$(dirname "$(test -L "$0" && readlink "$0" || echo "$0")")")
# Get the full path to ipfs binary bundled with ipfs-desktop
ipfs="$resources/app.asar.unpacked/node_modules/go-ipfs-dep/go-ipfs/ipfs"
exec "$ipfs" "$@"
$ ipfs version
ipfs version 0.4.19 |
I'm merging this and I've left a comment on the issue: #727 (comment) |
This adds
ipfs
to thePATH
on Linux and macOS. Will do the Windows version on a different PR. Right now, this is what's done:/usr/local/bin/ipfs
doesn't exist, we symlink to ouripfs.sh
file. Otherwise we do nothing.Addresses #727.